package com.xsoft.demo12;

import android.content.Context;
import android.content.SharedPreferences;

public class Utils {
    public static final String PREF_NAME = "account";
    public static final String KEY_PHONE_NUM = "phone_num";
    public static final String KEY_PSD = "psd";
    public static final String KEY_PSD_SWITCH = "psd_switch";
    public static final String VALUE_VERIFY_CODE = "891230";

    public static void setValue(Context context, String key, String value) {
        SharedPreferences preferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString(key, value);
        editor.commit();
    }

    public static String getValue(Context context, String key) {
        SharedPreferences preferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return preferences.getString(key, null);
    }

    public static void setSwitchState(Context context, String key, boolean value) {
        SharedPreferences preferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putBoolean(key, value);
        editor.commit();
    }

    public static boolean getSwitchState(Context context, String key) {
        SharedPreferences preferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return preferences.getBoolean(key, false);
    }
}
